package com.wxblockchain.core.manager;

import android.app.Activity;

import java.lang.ref.WeakReference;

/**
 * @Description activity管理类，主要用来获取当前的运行实例,对于跳转实用
 * @Author louyaming
 * @Date 2020/4/21
 */

public class ResumedActivityManager {
    private WeakReference<Activity> mCurrentActivityWeakRef;

    private ResumedActivityManager(){}

    private static class SingletonClassInstance {
        private static final ResumedActivityManager instance = new ResumedActivityManager();
    }

    public static ResumedActivityManager getInstance(){
        return SingletonClassInstance.instance;
    }

    public Activity getCurrentActivity() {
        Activity currentActivity = null;

        if (null != mCurrentActivityWeakRef){
            currentActivity = mCurrentActivityWeakRef.get();
        }

        return currentActivity;
    }

    public void setCurrentActivityWeakRef(Activity activity){
        mCurrentActivityWeakRef = new WeakReference<Activity>(activity);
    }
}
